let koa = require('koa');
let body = require('koa-body');
let static = require('koa-static');
let path = require('path');
let cons = require('./controllers');
let temp = require('./templating');

let app = new koa();
let port = 3030;

app.use(body());

app.use(temp);
app.use(cons());

app.use(static(path.join(__dirname, "static")));

app.use(async (ctx, next) => {
    if (ctx.status == 404) {
        ctx.body = "这是一个404界面"
    }
    await next();
})

app.listen(port, function () {
    console.log(`http://127.0.0.1:${port}`);
})